package com.zqxq.lottery.controller.esports;

import com.zqxq.common.constant.Result;
import com.zqxq.common.enums.CodeEnum;
import com.zqxq.lottery.entity.vo.esports.ESportsPlaywayVO;
import com.zqxq.lottery.entity.vo.esports.ESportsVO;
import com.zqxq.lottery.entity.vo.order.UserOrderBetVO;
import com.zqxq.lottery.service.esports.IESportsPlaywayService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class ESportsPlaytypeController extends ESportsBaseController {

    @Autowired
    private IESportsPlaywayService eSportsPlaywayService;
    @PostMapping("/playtype/get")
    public Result<ESportsVO> getESportsPlayway(@RequestParam String matchId,@RequestParam String playType){
        Result rs = new Result();
        try{
            ESportsPlaywayVO vo = eSportsPlaywayService.getESportsPlayway(matchId,playType);
            rs.setData(vo);
        }catch(Exception e){
            rs.setCode(CodeEnum.FAIL.getCode());
            rs.setMsg(CodeEnum.FAIL.getMsg());
            log.error("getESportsPlayway  Error:",e);
        }
        return rs;
    }

    @PostMapping("/playtype/choice")
    public Result<UserOrderBetVO> getMatchPlayTypeChoice(@RequestParam String userId,@RequestParam String period, @RequestParam String playType){
        Result rs = new Result();
        try{
            UserOrderBetVO vo = eSportsPlaywayService.getMatchPlayTypeChoice(userId,period,playType);
            rs.setData(vo);
        }catch(Exception e){
            rs.setCode(CodeEnum.FAIL.getCode());
            rs.setMsg(CodeEnum.FAIL.getMsg());
            log.error("getMatchPlayTypeChoice  Error:",e);
        }
        return rs;
    }

}
